package com.highcom.springboot0305mybatis.controller;

import com.highcom.springboot0305mybatis.bean.Emp;
import com.highcom.springboot0305mybatis.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class EmpController {

    @Autowired
    EmpService empService;

    @ResponseBody
    @PostMapping("/insert")
    public Emp saveEmp(Emp emp){
        empService.insertEmp(emp);
        return emp;
    }

    @ResponseBody
    @GetMapping("/emp")
    public Emp getById(@RequestParam("id") Integer id){
        return empService.getEmp(id);
    }

}
